﻿using System.Linq;
using CardInChina.Data.Entity;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using CardInChina.Data.Entity.Entity;
using System.Data.Objects.SqlClient;
using System.Data.Objects;

namespace CardInChina.Test
{
    
    
    /// <summary>
    ///This is a test class for MySqlFunctionsTest and is intended
    ///to contain all MySqlFunctionsTest Unit Tests
    ///</summary>
    [TestClass()]
    public class MySqlFunctionsTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for OldPassword
        ///</summary>
        [TestMethod()]
        public void OldPasswordTest()
        {
            using (var db = new CICEntities())
            {
               // var cc = db.Customers.FirstOrDefault(p => p.Account == "77是" && p.Password == MySqlFunctions.OldPassword("User@123"));
                var cc = db.Customers.Where(p => p.Account == "77是" && p.Password == MySqlFunctions.OldPassword("User@123"));
                //var cc = db.Customers.Where(p => p.Account == "77是" );

                var n = cc.Count();

                //var ss = db.CardInfoes.Where(p => p.CardName == "网易一卡通");
                //var n = ss.Count();
            }
 
        }

        /// <summary>
        ///A test for MD5
        ///</summary>
        [TestMethod()]
        public void MD5Test()
        {
            string data = "326.61"; // TODO: Initialize to an appropriate value
            string expected = "498bf4f69e2136fe82d5fedc599a1bd4"; // TODO: Initialize to an appropriate value
            string actual;
            actual = MySqlFunctions.MD5(data);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
    }
}
